<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../head.jsp">
	<jsp:param value="签约凭证上传" name="title" />
</jsp:include>

<!-- DROPZONE -->
<link rel="stylesheet" type="text/css" href="js/dropzone/dropzone.min.css" />
<script type="text/javascript" src="js/dropzone/dropzone.min.js"></script>
<script type="text/javascript">
$(function() {
	//$('#fileupload')匹配的元素必须是file选择框
	$('#fileupload').fileupload({
		url : "upload",
		dataType : 'json',
		formData:[{
			name:"model",
			value:"order"
		}],
		done : function(e, data) {
			//上传结果返回后，判断是否成功
			if(data.result.message){
				alert(data.result.message);
			}else{
				var p = $('<p/>');
				p.append("<input type='hidden' name='attachs' value='"+data.result.id+"'>");
				p.append("<span>"+data.result.fileName+"</span>");
				p.append('<img src="' + data.result.fileName + '" ' + " />');
				p.append("<a class='xx'>×</a>");
				p.appendTo('.files');
			}
		//	$(".fileinput-text").text("选择文件");
		},
		progressall : function(e, data) {
			var progress = parseInt(data.loaded / data.total * 100, 10);
			$(".fileinput-text").text("上传中..."+progress + '%');
		},
		start:function(){
			$(".fileinput-text").text("上传中...");
		}
	});
	
	/**
	 * 删除附件操作
	 */
	$(".files").on("click",".xx",function(){
		var id = $(this).prev().prev().val();
		var that = this;
		ajax({
			url:"delete/accessory?id=" + id,
			callback:function(data){
				var datas;
				if(window.JSON){
					datas = JSON.parse(data.response);
				}else{
					datas = eval("(" + data.response + ")");
				}
				if(datas){
					$(that).parent().remove();
				}
			}
		});
	});
});

	
</script>
</head>
<body>
<div class="container ">
		<div class="row " >
			<div id="content" class="col-lg-9 ">
				<div class = "dao">		
					<a class="section" href = "manager">学员管理</a>
					<i class="right chevron icon divider"></i>
					<a class="section" href = "student">签约与收款</a>
					<i class="right chevron icon divider"></i>
					<span class="active section">上传签约凭证</span>							
				</div>
			<div class="row">
				<div class="col-md-9 ">
				<!-- BOX -->
				<div class="box border blue">
					<div class="box-title">
						<h4><i class="fa fa-cloud-download"></i>上传签约凭证</h4>
						
						<div class="tools hidden-xs">
						<a href="#box-config" data-toggle="modal" class="config">
							<i class="fa fa-cog"></i>
						</a>
						<a href="javascript:;" class="reload">
							<i class="fa fa-refresh"></i>
						</a>
						<a href="javascript:;" class="collapse">
							<i class="fa fa-chevron-up"></i>
						</a>
						<a href="javascript:;" class="remove">
							<i class="fa fa-times"></i>
						</a>
					</div>
				</div>
				<div class="box-body">
				<form action="upload?upid=${upid}" class="dropzone" id="my-awesome-dropzone" method = "post">
					<div class="fallback">
						<input name="file" type="file" multiple="" />
					</div>
					<a href = "student?upid=${upid}" class="btn btn-primary" style = "float:right">确定上传</a>
				  </form>
					<!-- <form action = "student" method="post">
					 <span class="btn btn-success fileinput-button"> 
						<span class="fileinput-text"></span> 
						<input id="fileupload" type="file" name="files[]" multiple>
					<div class="files"></div>
					</span>
					 
					  	<button class="btn btn-primary" style = "float:right">确定上传</button>
					 
					  </form> -->
				</div>
				
			</div>
			<!-- /BOX -->
		</div>
	</div>
	</div>
	</div>
</div>
</body>
</html>